package cn.edu.wynu.api.timeapi.time;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DataTimeFormatterLearn {
    public static void main(String[] args) {
        // 将时间按指定的格式输出出来
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
        System.out.println(pattern.format(LocalDateTime.now()));

        // 将字符串时间按照指定的格式解析成时间对象
        String time1 = "2019/01/01 00:12:12";
        LocalDateTime time = LocalDateTime.parse(time1, pattern);
        System.out.println(time);
    }
}
